﻿using LiveCharts;
using LiveCharts.Wpf;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using static ImTools.ImMap;

namespace Manson.PrismWPFUIBase.ViewModels
{
    public class UserRatioViewModel : BindableBase
    {

        public UserRatioViewModel()
        {
            InitDate();
        }


        private SeriesCollection _seriesList;
        public SeriesCollection SeriesList
        {
            get { return _seriesList; }
            set { SetProperty(ref _seriesList, value); }
        }
        private void InitDate()
        {
            SeriesList = new SeriesCollection();

            List<LiveChartzModel> liveChartzs = new List<LiveChartzModel>()
            {
                new LiveChartzModel()
                {
                    Title="国产车",
                    Value=200,
                    Backgrond="#DC143C"
                },
                new LiveChartzModel()
                {
                    Title="进口车",
                    Value=100,
                    Backgrond="#4169E1"
                },


            };

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                SeriesList.Clear();
                foreach (var series in liveChartzs)
                {
                    SeriesList.Add(new PieSeries()
                    {
                        Title = series.Title ,
                        Values = new ChartValues<double>(new double[] { series .Value}),
                        Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(series.Backgrond))

                    });
                }

            });
            ////国产车
            //ChartValues<double> gcValues=new ChartValues<double> ();
            //gcValues.Add(183);
            //PieSeries pieSeries=new PieSeries();
            //pieSeries.Title = "国产车";
            //pieSeries .Values = gcValues;
            //SeriesList.Add(pieSeries);

            ////进口产车
            //ChartValues<double> jkValues = new ChartValues<double>();
            //gcValues.Add(123);
            //PieSeries jkpieSeries = new PieSeries();
            //pieSeries.Title = "国产车";
            //pieSeries.Values = gcValues;
            //SeriesList.Add(jkpieSeries);
        }


    }

    public class LiveChartzModel
    {
        public string Title { get; set; }

        public double Value { get; set; }

        public string Backgrond { get; set; }

    }



}
